#include <string>

#include "fundamental.h"

Fundamental::ID Fundamental::JenkinsPHF( const char* str, unsigned int strLength )
{
	unsigned int hash = 0;
	for( unsigned int i = 0; i < strLength; ++i )
	{
		hash += str[i];
		hash += ( hash << 10 );
		hash ^= ( hash >> 6 );
	}
	hash += ( hash << 3 );
	hash ^= ( hash >> 11 );
	hash += ( hash << 15 );

	return hash;
}

Fundamental::ID Fundamental::JenkinsPHF( const std::string& str )
{
	return Fundamental::JenkinsPHF( str.c_str(), static_cast< unsigned int >( str.size() ) );
}